<template>
  <div class="app-container">
    <el-card>
      <template v-slot:header>
        <span>{{ $t('route.base.company.info') }}-详情</span>
        <span style="float: right; ">
          <apj-permission-form-action
            @save="handleSave"
            @cancel="handleCancel"
          />
          <el-button @click="handleCancel">取消</el-button>
        </span>
      </template>

      <el-form
        ref="form"
        :model="entity"
        :rules="rules"
        disabled
        label-width="120px"
      >
          <el-col :span="8">
            <el-form-item
              :label="$t('base.company.info.name')"
              :required="true"
            >
              <el-input v-model="entity.name" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item
              :label="$t('base.company.info.alise_name')"
            >
              <el-input v-model="entity.aliseName" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item
              :label="$t('base.company.info.company_url')"
            >
              <el-input v-model="entity.companyUrl" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item
              :label="$t('base.company.info.remark')"
            >
              <el-input type="textarea" v-model="entity.remark" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item
              :label="$t('base.company.info.img')"
            >
              <el-input v-model="entity.img" type="number"/>
            </el-form-item>
          </el-col>
      </el-form>
    </el-card>
  </div>
</template>

<script>
//import * as InfoApi from '@/api/base/company/info'
import axios from 'axios'

export default {
  name: 'BaseCompanyInfoEdit',
  components: {},
  data() {
    return {
      entityId: '',
      entity: {},
      rules: {
name:[{ required: true, message: '', trigger: 'blur' }]      }
    }
  },
  created() {
    this.entityId = this.$route.query.id || ''
    this.initPage()
  },
  methods: {
    initPage() {
      // 初始化页面
      const params = {}
      params.entityId = this.entityId
       const actionUrl = this.HOST + '/base/company/info/'+ 'initEditPage'
            axios({
              url: actionUrl,
              method: 'post',
              params: { id: this.entityId }
            }).then(response => {
      //InfoApi.initEditPage(params).then(response => {
        const data = response.data
        this.entity = data.entity
      })
    },

    handleSave() {
	      // 保存
	      const data = Object.assign({}, this.entity)
       const actionUrl = this.HOST + '/base/company/info/'+ 'save'
            axios({
              url: actionUrl,
              method: 'post',
              data: data
            }).then(response => {
	      //InfoApi.saveEntity(data).then(response => {
	        this.$router.back()
	      })
    },
    handleCancel() {
      this.$router.back()
    }
  }
}
</script>
